/**
 * 被互斥阻塞(Blocked by a mutex)
 * 
 * @author fireway
 * @since 2019年 01月 31日 星期四 07:03:49 CST
 */
package concurrency;

public class MultiLock {
    public synchronized void f1(int count) {
        if(count-- > 0) {
            System.out.println("f1() calling f2() with count " + count);
            f2(count);
          }     
    }
    
    public synchronized void f2(int count) {
        if (count-- > 0) {
            System.out.println("f2() calling f1() with count " + count);
            f1(count);
        }
    }
    
    public static void main(String[] args) {
        final MultiLock multiLock = new MultiLock();

        new Thread() {
            public void run() {
                multiLock.f1(10);
            }
        }.start();
    }
}
